﻿using System;
using System.Collections.Generic;
using System.Text;

using System.Diagnostics;
using EnvDTE;
using DoxygenBrowserAddin.Utils;
using DoxygenBrowser.Common.Model;

namespace DoxygenBrowserAddin.Data
{
    public class TokenDictionary
    {
        private const string CONST_CLASS_MEMBER = "clm";
        private const string CONST_CLASS = "cl";
        private const string CONST_FILE = "file";

        private int _iNumEntries;

        private Dictionary<string, FileLocation> _dictionaryFileLoc;

        /// <summary>
        /// Initializes a new instance of the <see cref="TokenDictionary"/> class.
        /// </summary>
        public TokenDictionary()
        {
            _dictionaryFileLoc = new Dictionary<string, FileLocation>();
        }

        /// <summary>
        /// Gets the num entries.
        /// </summary>
        /// <value>The num entries.</value>
        public int NumEntries
        {
            get { return _iNumEntries; }
        }

        public void AddTokenEntry(string strTokenKey, FileLocation fileLocation)
        {

            if (!string.IsNullOrEmpty(strTokenKey) &&
              (!_dictionaryFileLoc.ContainsKey(strTokenKey)))
            {
                _dictionaryFileLoc.Add(strTokenKey, fileLocation);
            }
            else
            {

            }

            _iNumEntries++;
        }

        /// <summary>
        /// Finds the specified code location.
        /// </summary>
        /// <param name="innerScope"></param>
        /// <returns></returns>
        public FileLocation Find(string innerScope)
        {
            FileLocation result = null;


            string key = string.Empty;

            key = Scope.Normalizate(innerScope);

            if (_dictionaryFileLoc.ContainsKey(key))
            {
                result = _dictionaryFileLoc[key];
            }

            return result;
        }

    }
}
